package com.example.demo.controller;

import com.example.demo.model.Thmana;
import com.example.demo.service.IThmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Api(tags = "退货信息")
@RestController
@RequestMapping("/swagger11")
public class ThmanaController {
    @Autowired
    private IThmanaService thmanaService;
    @CrossOrigin
    @ApiOperation(value="添加退货信息")
    @PostMapping("/insertThmana")
    public int insertThmana(@RequestBody Thmana thmana){
        System.out.println("进入添加补货信息接口" );
        return thmanaService.insertThmana(thmana);
    }

    @PostMapping("/getAllThmana")
    public List<Thmana> getAllThmana(@RequestBody Thmana thmana)
    {
        System.out.println("进入查询方法");
        List<Thmana> listThmana=thmanaService.getAllThmana(thmana);
        return listThmana;
    }
    @PostMapping("/editThmana")
    public int EditThmana(@RequestBody Thmana thmana){
        System.out.println("添加修改方法");
        return thmanaService.updateThmana(thmana);
    }
    @GetMapping("/delThmana")
    public int Delete(int lbid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(lbid!=0){
            Thmana thmana=new Thmana();
            thmana.setLbid(lbid);
            returnValues=thmanaService.deleteThmana(thmana);
        }
        return returnValues;
    }

    @GetMapping("/getOneThmana")
    public Thmana getThmana(int lbid){
        Thmana thmana=new Thmana();
        System.out.println("进入单条查询方法");
        if(lbid!=0){
            Thmana thmana1=new Thmana();
            thmana1.setLbid(lbid);
            thmana=thmanaService.getThmana(thmana1);
            System.out.println("返回的数据集合为:"+thmana.getLbid());
        }
        return thmana;
    }
}
